package com.zqj.project.factory;

import com.zqj.project.common.database.mybatis.conditions.Wraps;
import com.zqj.project.common.database.mybatis.conditions.query.LbqWrapper;
import com.zqj.project.entity.ReviewPO;
import com.zqj.project.model.Review;

import java.util.Objects;

/**
 * @Description: ReviewFactory
 * @Author: 22001010704 Zhang Qijian
 * @CreateTime: 2024/12/8 18:53
 * @Version: 1.0
 */
public class ReviewFactory {

    private ReviewFactory() {
        throw new IllegalStateException("Utility Class");
    }

    public static LbqWrapper<ReviewPO> lbqWrapper(Review review) {
        return Wraps.<ReviewPO>lbQ().eq(Objects.nonNull(review.getUserId()), ReviewPO::getUserId, review.getUserId())
                .eq(Objects.nonNull(review.getOrderId()), ReviewPO::getOrderId, review.getOrderId())
                .eq(Objects.nonNull(review.getProductId()), ReviewPO::getProductId, review.getProductId())
                .orderByDesc(ReviewPO::getCreateTime);
    }

}